* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

#app {
    width: 100%;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
    opacity: 1;
    transform: translateX(0);
}

/* 开始界面 */
#startScreen {
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: radial-gradient(circle at center, rgba(0,0,0,0.3), rgba(0,0,0,0.6));
}

.game-title {
    text-align: center;
    margin-bottom: 50px;
    animation: fadeInDown 1s ease-out;
}

.game-title h1 {
    font-size: 4rem;
    margin-bottom: 10px;
    text-shadow: 0 4px 20px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, #ff6b6b, #ffd93d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.5rem;
    opacity: 0.9;
    font-weight: 300;
}

.game-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
    max-width: 800px;
    width: 100%;
}

.mode-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    text-align: center;
    color: #fff;
}

.mode-btn:hover {
    transform: translateY(-5px);
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.mode-icon {
    display: block;
    font-size: 3rem;
    margin-bottom: 15px;
}

.mode-name {
    display: block;
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.mode-desc {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.4;
}

.game-instructions {
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    backdrop-filter: blur(10px);
    animation: fadeInUp 1s ease-out 0.5s both;
}

.game-instructions h3 {
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.game-instructions ul {
    list-style: none;
    padding-left: 0;
}

.game-instructions li {
    margin-bottom: 12px;
    padding-left: 25px;
    position: relative;
}

.game-instructions li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #ffd93d;
    font-weight: bold;
}

/* 游戏界面 */
#gameScreen {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.game-info {
    display: flex;
    gap: 30px;
    font-size: 1.1rem;
}

.game-info span {
    font-weight: 500;
}

.controls {
    display: flex;
    gap: 10px;
}

.controls button {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    padding: 10px 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.controls button:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.game-field {
    background: rgba(0,0,0,0.3);
    border-radius: 20px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.1);
}

.start-line, .finish-line {
    position: absolute;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
}

.start-line {
    top: 10px;
    left: 10px;
    background: #4CAF50;
}

.finish-line {
    top: 10px;
    right: 10px;
    background: #FF5722;
}

#gameCanvas {
    width: 100%;
    height: calc(100% - 50px);
    margin-top: 40px;
    border-radius: 10px;
    background: linear-gradient(90deg, 
        rgba(76,175,80,0.1) 0%, 
        rgba(255,255,255,0.05) 50%, 
        rgba(255,87,34,0.1) 100%);
    position: relative;
    overflow: hidden;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-display, .player-list {
    background: rgba(0,0,0,0.2);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.status-display h4, .player-list h4 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #ffd93d;
}

#statusText {
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.command-text {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.command-text.green {
    background: rgba(76,175,80,0.3);
    color: #4CAF50;
}

.command-text.red {
    background: rgba(244,67,54,0.3);
    color: #f44336;
}

.player-list {
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.player-item.eliminated {
    opacity: 0.5;
    text-decoration: line-through;
}

.player-item.current-player {
    background: rgba(255,217,61,0.2);
    border: 1px solid rgba(255,217,61,0.5);
}

.player-position {
    font-weight: bold;
    color: #ffd93d;
}

.mobile-controls {
    display: none;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.control-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    padding: 20px 30px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    color: #fff;
}

.control-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.control-btn:active {
    transform: scale(0.95);
}

/* 游戏结束界面 */
#endScreen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, rgba(0,0,0,0.4), rgba(0,0,0,0.7));
}

.result-container {
    background: rgba(0,0,0,0.3);
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255,255,255,0.1);
    max-width: 500px;
    width: 100%;
}

#resultTitle {
    font-size: 2.5rem;
    margin-bottom: 30px;
    background: linear-gradient(45deg, #ff6b6b, #ffd93d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.stat {
    text-align: center;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 10px;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #ffd93d;
}

.result-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.result-actions button {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 15px;
    padding: 15px 25px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    backdrop-filter: blur(10px);
}

.result-actions button:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

/* 玩家角色 */
.player {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 10;
}

.player.current-player {
    box-shadow: 0 0 20px rgba(255,217,61,0.8);
    animation: pulse 2s infinite;
}

.player.moving {
    z-index: 20;
}

.player.eliminated {
    opacity: 0.3;
    filter: grayscale(1);
}

/* 游戏管理员 */
.game-master {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    z-index: 15;
    transition: all 0.5s ease;
}

.game-master.watching {
    transform: translateX(-50%) rotate(0deg);
}

.game-master.turned {
    transform: translateX(-50%) rotate(180deg);
}

/* 动画 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 20px rgba(255,217,61,0.8);
    }
    50% {
        box-shadow: 0 0 40px rgba(255,217,61,1);
    }
    100% {
        box-shadow: 0 0 20px rgba(255,217,61,0.8);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.eliminated {
    animation: shake 0.5s ease-in-out;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-title h1 {
        font-size: 3rem;
    }
    
    .game-modes {
        grid-template-columns: 1fr;
    }
    
    .game-area {
        grid-template-columns: 1fr;
    }
    
    .side-panel {
        display: none;
    }
    
    .mobile-controls {
        display: flex;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .game-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
    }
}

/* 设置界面 */
.settings-section {
    text-align: center;
    margin-top: 30px;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#settingsScreen {
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: radial-gradient(circle at center, rgba(0,0,0,0.3), rgba(0,0,0,0.6));
}

.settings-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInUp 0.5s ease-out;
}

.settings-container h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.settings-group {
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-group h3 {
    margin-bottom: 20px;
    font-size: 1.3rem;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.setting-item {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.setting-item label {
    flex: 1;
    min-width: 200px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
}

.setting-item input[type="range"] {
    flex: 1;
    min-width: 150px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #FFD700;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #FFA500;
}

.setting-item select {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
}

.setting-item select option {
    background: #333;
    color: #fff;
}

.setting-value {
    min-width: 50px;
    text-align: center;
    font-weight: bold;
    color: #FFD700;
    font-size: 1rem;
}

.settings-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.settings-actions button {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

#resetSettingsBtn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: #fff;
}

#saveSettingsBtn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: #fff;
}

#backFromSettingsBtn {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: #fff;
}

.settings-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

@media (max-width: 480px) {
    .game-title h1 {
        font-size: 2.5rem;
    }
    
    .mode-btn {
        padding: 20px 15px;
    }
    
    .controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .controls button {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .settings-container {
        padding: 20px;
        margin: 10px;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-item label {
        min-width: auto;
        margin-bottom: 10px;
    }
    
    .settings-actions {
        flex-direction: column;
        align-items: stretch;
    }
}